package xm.erzhan.repository;

import xm.erzhan.models.UserEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;

public interface UserRepository  extends JpaRepository<UserEntity, Integer>{

    @Modifying
    @Transactional
    @Query("update UserEntity user set user.userName=:qUserName, user.passWord=:qPassWord, user.lastLoginTime=:qLastLoginTime where user.id=:qId")
    public void updateUser(@Param("qUserName") String userName,
                           @Param("qPassWord") String passWord,
                           @Param("qLastLoginTime") Long lastLoginTime,
                           @Param("qId") Integer id);

    public UserEntity findUserByUserName(@Param("qUserName") String userName);

}
